package com.woniu.order.controller;

import com.woniu.common.utils.PageData;
import com.woniu.common.utils.ResponseData;
import com.woniu.common.utils.ResponseEnum;
import com.woniu.order.pojo.ZfOrder;
import com.woniu.order.service.ZfOrderService;
import com.woniu.order.service.ZfTraderdetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: ECP
 * @description:
 * @create: 2024-11-26 12:03
 **/
@RestController
@RequestMapping("/zfOrder")
public class ZfRealOrderController {
    @Autowired
    private ZfTraderdetailsService zfTraderdetailsService;
    @Autowired
    private ZfOrderService zfOrderService;

    @PostMapping("/queryAllPage")
    public ResponseData<?> queryAllPage(@RequestBody PageData<ZfOrder> pageData){
        return zfOrderService.queryAllPage(pageData);
    }
    @PostMapping("/addOrder")
    public ResponseData<?> addOrder(String code){
        return zfTraderdetailsService.addOrder(code);
    }
    @PostMapping("/addOrder2")
    public ResponseData<?> addOrder2(String code){
        return zfTraderdetailsService.addOrder2(code);
    }
    @PostMapping("/batchDel")
    public ResponseData<?> batchDel(@RequestBody List<String> ids){
        if (ids == null || ids.isEmpty()) {
            return new ResponseData<>().fail(ResponseEnum.FAIL);
        }
        return zfOrderService.batchDelete(ids);
    }
    @PostMapping("/queryById")
    public ResponseData<?> queryById(Integer id){
        if (id == null) {
            return new ResponseData<>().fail(ResponseEnum.FAIL);
        }
        return new ResponseData<>().ok(zfTraderdetailsService.getById(id));
    }
}